import { get, post, del, put } from '@/common/js/httpHelper'
import * as url from '@/common/js/interfaces'

const getTeamList = async () => {
  const getTeamListApiUrl = url.teamListUrl + '/all'
  const result = await get(getTeamListApiUrl)
  return result.data
}

const getTeamListWithQuery = async (params) => {
  const result = await post(url.teamListUrl + '/list', params)
  return result.data
}

const deleteTeamById = async (id) => {
  const result = await del(url.teamListUrl + '/' + id, id)
  return result
}

const addTeam = async (team) => {
  const result = await post(url.teamListUrl, team)
  return result
}

const updateTeam = async (team) => {
  const result = await put(url.teamListUrl + '/' + team.id, team)
  return result
}

const getTeamById = async (teamId) => {
  const result = await get(url.teamListUrl + '/' + teamId)
  return result.data
}

export default {
  getTeamList: getTeamList,
  getTeamListWithQuery: getTeamListWithQuery,
  deleteTeamById: deleteTeamById,
  addTeam: addTeam,
  updateTeam: updateTeam,
  getTeamById: getTeamById
}
